# OrderUpdateType:
#   - DEAL: 成交回报
#   - CANCEL: 撤单。volume是撤回未成交的量，price是对应的价格


class OrderUpdate:
    strategy_name = ''
    strategy_order_id = ''
    system_order_id = ''
    update_type = ''
    inst_id = ''
    direction = ''
    volume = 0.0  # 成交量
    price = 0.0   # 成交价
    amount = 0.0  # 净成交金额（考虑手续费后）
    fee = 0.0     # 手续费

    def __init__(self, strategy_name, strategy_order_id, system_order_id, update_type,
                 inst_id, direction, volume, price, amount=0, fee=0):
        self.strategy_name = strategy_name
        self.strategy_order_id = strategy_order_id
        self.system_order_id = system_order_id
        self.update_type = update_type
        self.inst_id = inst_id
        self.direction = direction
        self.volume = volume
        self.price = price
        self.amount = amount
        self.fee = fee

    def __str__(self):
        return '<Order update: {}, {}, {}, {}, {}, {}, {}, {}, {}>'.\
                format(self.strategy_name, self.system_order_id, self.strategy_order_id,
                       self.inst_id, self.update_type, self.volume,
                       self.price, self.amount, self.fee)
